unit MapName;

interface

uses
  Database,
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons;

type
  TFormMapName = class(TForm)
    BtnOK: TBitBtn;
    BtnSkip: TBitBtn;
    EditMap: TEdit;
    label2: TLabel;
    procedure EditMapChange(Sender: TObject);
    procedure EditMapKeyPress(Sender: TObject; var Key: Char);
    procedure BtnSkipClick(Sender: TObject);
    procedure BtnOKClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    linked: boolean;
  end;

var
  FormMapName: TFormMapName;

implementation

uses Map;

{$R *.DFM}

procedure TFormMapName.FormCreate(Sender: TObject);
begin
  linked:=false;
end;

procedure TFormMapName.BtnSkipClick(Sender: TObject);
begin
  close;
end;

procedure TFormMapName.EditMapChange(Sender: TObject);
begin
  if length(EditMap.text) > 0 then BtnOK.enabled:=true
  else BtnOK.enabled:=false;
end;

procedure TFormMapName.EditMapKeyPress(Sender: TObject; var Key: Char);
begin
  if key = #13 then begin
    BtnOK.click;
    key:=#0;
  end;
end;

procedure TFormMapName.BtnOKClick(Sender: TObject);
begin
  if EditMap.text = '' then begin
    messagedlg('Please enter a map level name',mtinformation,[mbok],0);
    EditMap.setfocus;
    exit;
  end;
  if pos('"',EditMap.text) > 0 then begin
    messagedlg('Map level names cannot contain quotes',mtinformation,[mbok],0);
    EditMap.selectall;
    EditMap.setfocus;
    exit;
  end;
  if Datawell.IsMap(EditMap.text) then begin
    messagedlg('A map level of that name already exists',mtinformation,[mbok],0);
    EditMap.selectall;
    EditMap.setfocus;
    exit;
  end;
  linked:=true;
  close;
end;

end.
